with ta as(select avg(salary) as avg_salary,company_name
from works 
group by company_name)
select a.id ,a.person_name
from employee as a
where exists(
select 1
from works b
where b.salary>(
select avg_salary
from ta where ta.company_name=b.company_name) 
and b.id=a.id
);